namespace DotNetNuke.Services.Scheduling
{
    using System;
    using System.Diagnostics;
    using System.Runtime.CompilerServices;
    using System.Threading;
    using DotNetNuke.Common.Utilities;

    public abstract class SchedulerClient
    {
        private string _ProcessMethod = Null.NullString;
        private DotNetNuke.Services.Scheduling.ScheduleHistoryItem _ScheduleHistoryItem = new DotNetNuke.Services.Scheduling.ScheduleHistoryItem();
        private string _SchedulerEventGUID = Null.NullString;
        private string _Status = Null.NullString;

        public event WorkCompleted ProcessCompleted;

        public event WorkErrored ProcessErrored;

        public event WorkProgressing ProcessProgressing;

        public event WorkStarted ProcessStarted;

        public void Completed()
        {
            //WorkCompleted refObjectHelperS0 = this.ProcessCompletedEvent;
            WorkCompleted refObjectHelperS0 = this.ProcessCompleted;
            if (refObjectHelperS0 != null)
            {
                SchedulerClient refObjectHelperS1 = this;
                refObjectHelperS0(ref refObjectHelperS1);
            }
        }

        public abstract void DoWork();
        public void Errored(ref Exception objException)
        {
            WorkErrored refObjectHelperS0 = this.ProcessErrored;
            if (refObjectHelperS0 != null)
            {
                SchedulerClient refObjectHelperS1 = this;
                refObjectHelperS0(ref refObjectHelperS1, ref objException);
            }
        }

        public void Progressing()
        {
            WorkProgressing refObjectHelperS0 = this.ProcessProgressing;
            if (refObjectHelperS0 != null)
            {
                SchedulerClient refObjectHelperS1 = this;
                refObjectHelperS0(ref refObjectHelperS1);
            }
        }

        public void Started()
        {
            WorkStarted refObjectHelperS0 = this.ProcessStarted;
            if (refObjectHelperS0 != null)
            {
                SchedulerClient refObjectHelperS1 = this;
                refObjectHelperS0(ref refObjectHelperS1);
            }
        }

        public string aProcessMethod
        {
            get
            {
                return this._ProcessMethod;
            }
            set
            {
                this._ProcessMethod = value;
            }
        }

        public DotNetNuke.Services.Scheduling.ScheduleHistoryItem ScheduleHistoryItem
        {
            get
            {
                return this._ScheduleHistoryItem;
            }
            set
            {
                this._ScheduleHistoryItem = value;
            }
        }

        public string SchedulerEventGUID
        {
            get
            {
                return this._SchedulerEventGUID;
            }
            set
            {
                this._SchedulerEventGUID = value;
            }
        }

        public string Status
        {
            get
            {
                return this._Status;
            }
            set
            {
                this._Status = value;
            }
        }

        public int ThreadID
        {
            get
            {
                return Thread.CurrentThread.ManagedThreadId;
            }
        }
    }
}

